import { createStore, Store, useStore as useVuexStore } from 'vuex'
import { IRootState, IStoreType } from './type'
import login from './login/login'
import general from './main/general/general'
import manage from './main/manage/manage'
import hardware from './main/hardware/hardware'

const store = createStore<IRootState>({
  state() {
    return {
      name: 'flitsneak',
      email: 'flitsneak@gmail.com',
      roleId: 1,
      url: null
    }
  },
  mutations: {},
  getters: {},
  actions: {},
  modules: {
    login,
    general,
    manage,
    hardware
  }
})

export function setupStore() {
  store.dispatch('login/loadLocalLogin')
}

export function useStore(): Store<IStoreType> {
  return useVuexStore()
}
export default store
